"""
__author__="yanwei"
__describe__="新建营销计划（第三步）"
__API__="/plan/step/:id"
"""
from tool_class.marketing_plan_steptwo import MarketingPlanSteptwo
import requests
import json
from lib.operate_excel import OperateExcel
from tool_class.get_token import GetToken
from conf.readConfig import ReadConfig
from lib.conect_database import Conne_DB
import os


class DingDingApproval():
    def access_token(self):
        host = ReadConfig().get_url("dingding_url")
        appkey = ReadConfig().get_dingding("appkey")
        appsecret = ReadConfig().get_dingding("appsecret")

        data = {
            "appkey": appkey,
            "appsecret": appsecret
        }

        headers = {
            "Content-Type": "application/json"
        }

        resp = requests.get(url=host + "/gettoken", params=data, headers=headers)
        result = resp.json()
        print(result["access_token"])
        return result["access_token"]

    def process_instance_id(self):
        conne_db = Conne_DB().conne_db()
        sql = "select process_instance_id from approval where id = (select approval_id from market_approval where data -> 'info.title' =)"

        # 获取实例id，审批实例详情时需要该id，

    def process_instance(self):
        # 获取token
        access_token = DingDingApproval().access_token()


if __name__ == "__main__":
    DingDingApproval().process_instance()
